package com.lucenten.collect;

import cn.quevo.common.entity.ResponseResult;
import cn.quevo.common.entity.ResultEntity;
import cn.quevo.core.spring.SpringController;
import cn.quevo.core.spring.util.PropertiesUtils;
import cn.quevo.core.spring.util.WebUtils;
import com.lucenten.collect.gnss.runnable.GnssUnZipRunService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Stream;

@RestController("testController")
public class TestController extends SpringController {
    private final static String root = new PropertiesUtils("/conf/gnss.properties").getProperties("collect.source");
//    @Resource(name = "gnssUnZipRunService")
    @Resource(name = "gnssUnZipRangeService")
    private GnssUnZipRunService gnssUnZipRunService;
    @GetMapping("/index")
    public ResultEntity index(){
        Long start = new Date().getTime();
        System.out.println("开始时间："+start);
        Context.startDate = new Date();
//        GnssUnZipRunService gnssUnZipRunService = SpringUtil.getBean(GnssUnZipRunServiceImpl.class);
        gnssUnZipRunService.run(root );
//        gnssUnZipRunService.run("D:/tmp/collect/20300000");
//        gnssUnZipRunService.run("D:/tmp/collect/20190409");
        Long end = new Date().getTime();
        System.out.println("截至时间："+end);
        System.out.println("时间差："+(end - start));
        Map<String,Long> result = new LinkedHashMap<>();
        result.put("start",start);
        result.put("end",end);
        result.put("dif",(end - start));
        return ResponseResult.success(result);
    }

    public static void main(String[] args) {
        System.out.println(System.getProperty("user.dir"));
    }
}
